home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1998-08-10 | 58.2 KB | 2,072 lines
# # version 2.27c open(STDERR,">&STDOUT"); &readparse; print "Content-type: text/html\n\n"; # #********* BEGIN BODY******************** $homepage="http://localhost/"; $password="password"; $cgilocation="webdata.cgi"; $logfile='C:\WebSite\htdocs\dbname_data.log'; $fieldnames='C:\WebSite\htdocs\dbname_fields.log'; $members='C:\WebSite\htdocs\dbname_members.log'; $reportdata='C:\WebSite\htdocs\dbname_report.log'; $code='0000'; #CHANGE SEARCHPAGE TO CUSTOM URL TO CHANGE "search again" LINK. $searchpage="$cgilocation?cgifunction=user"; &user if ($user_data{cgifunction} eq "user"); &add if ($user_data{cgifunction} eq "Add"); &adminsearch if ($user_data{cgifunction} eq "Search/modify"); &maintenance if ($user_data{cgifunction} eq "maintenance"); &delete if $user_data{cgifunction} eq "delete"; &modify if $user_data{cgifunction} eq "modify"; &admin if $user_data{cgifunction} eq "admin"; &usersearch if $user_data{cgifunction} eq "Search"; &import if $user_data{cgifunction} eq "Import data"; &import2 if $user_data{cgifunction} eq "import2"; &export if $user_data{cgifunction} eq "Export data"; &export2 if $user_data{cgifunction} eq "export2"; &cache if $user_data{cgifunction} eq "cache"; &fieldmod if $user_data{cgifunction} eq "Modify fields"; &deleteField if $user_data{cgifunction} eq "deleteField"; &insertField if $user_data{cgifunction} eq "insertField"; &renameField if $user_data{cgifunction} eq "renameField"; &nextprev if $user_data{cgifunction} eq "Next Page"; &nextprev if $user_data{cgifunction} eq "Previous Page"; &members if $user_data{cgifunction} eq "Members"; &addmember if $user_data{cgifunction} eq "Add Member"; &deletemember if $user_data{cgifunction} eq "Delete Member"; &memberpage if $user_data{cgifunction} eq "memberpage"; &memberadd if $user_data{cgifunction} eq "add"; &reportpage if $user_data{cgifunction} eq "Customize Pages"; &modifyreport if $user_data{cgifunction} eq "Modify Pages"; &deleteset if $user_data{cgifunction} eq "deleteset"; &form if ($user_data{cgifunction} eq "form"); #*******BEGIN FORM SUBROUTINE****** sub form { pop(@value); $id=$user_data{id}; open(REPORT, "<$reportdata"); @reportData=<REPORT>; close REPORT; $reportColor=$reportData[0]; chop($reportColor); $reportHeader=$reportData[1]; chop($reportHeader); $reportHeader=~s/\<\;/</g; $reportHeader=~s/::/\n/g; $reportSequence=$reportData[2]; chop($reportSequence); @sequence=split(/:/,$reportSequence); $reportSort=$reportData[3]; chop($reportSort); $reportOrder=$reportData[4]; chop($reportOrder); $reportLines=$reportData[5]; chop($reportLines); $reportForm=$reportData[6]; chop($reportForm); print " <HEAD><TITLE>FORM DATA</TITLE></HEAD> <BODY BGCOLOR=\"$reportColor\"> $reportHeader <TABLE width=100% bgcolor=white border=1> <TH WIDTH=20%><TH> "; open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); open(READLOG,"<$logfile")||die "Could not open $logfile"; @entrydata = <READLOG>; close READLOG; foreach $entry (@entrydata) { @parsed = split(/::/,$entry); if ($parsed[0] eq $id) {@data = @parsed}; }; $num = @fields; shift(@data); for ($i=0;$i<$num;$i++) { # $data[$i]=~s/\"/'"'/ge; $data[$i]=~s/^([0-9a-zA-Z_\-\.\~]+\@[0-9a-zA-Z_\-\.\~]+\.[0-9a-zA-Z_\-\.\~]+)/<A HREF=mailto:$1>$1<\/A>/; if ($data[$i]=~/^([^ ]+\.(gif|jpg))$/) { $data[$i]="<IMG SRC=$1>"; } else { $data[$i]=~s/^(http[^ ]+)/<A HREF=$1>$1<\/A>/; }; print "<TR><TD><B>$fields[$i]<TD>$data[$i]\n"; }; print " </TABLE> <A HREF=\"$cgilocation?$user_data{query}\"><B>Back to Search Results</B></A> \ \; <A HREF=\"$searchpage\"><B>Search Again</B></A> \ \; <A HREF=\"$homepage\"><B>Return to Homepage</B></A> "; }; #*******END FORM SUBROUTINE****** #******BEGIN DELETE SET SUBROUTINE******* sub deleteset { &memberpass; open(READLOG,"<$logfile"); @entries = <READLOG>; close READLOG; foreach $line (@entries) { @fields=split(/::/,$line); $len=@fields; $owner=$fields[$len-1]; chop($owner); $id=$_; if ((!($user_data{foundset}=~$fields[0]))||(($userid ne "admin")&&($userid ne $owner))) { push(@result,$line); }; }; open(PUTLOG, ">$logfile") || die "Content-type: text/html\n\n <BODY BGCOLOR=WHITE><CENTER><H2>Could not open the file $logfile<P> If you have moved the file, you can correct this by changing lines 10 and 11 of the webdata_[database name].cgi script to show the absolute path to the file.<P><P><P></h2> This cgi error was "; print PUTLOG (@result); close PUTLOG; @value=(); if ($userid eq "admin") {&admin} else {&memberpage}; }; #******END DELETE SET SUBROUTINE********* #******BEGIN MODIFY REPORT.LOG FILE******* sub modifyreport { open(FILE,">$reportdata")||die "Could not open $reportdata"; $user_data{header}=~s/\r\n/::/g; $user_data{header}=~s/\<\;/</g; $user_data{searchHeader}=~s/\r\n/::/g; $user_data{searchHeader}=~s/\<\;/</g; if ($user_data{form} eq "on") { $form=1; } else { $form=0; }; #chop($user_data{seqnums}); print FILE ("$user_data{color}\n$user_data{header}\n$user_data{seqnums}\n$user_data{sort}\n"); print FILE ("$user_data{order}\n$user_data{numrows}\n$form\n"); print FILE ("$user_data{searchHeader}\n$user_data{searchInfo}\n"); close FILE; &reportpage; }; #******END MODIFY REPORT.LOG FILE******* #*******BEGIN REPORT PAGE SUBROUTINE******** sub reportpage { &checkpass; open(FILE,"<$reportdata")||die "Could not open $reportdata"; @reportData=<FILE>; close FILE; open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); $len=@fields; $reportColor=$reportData[0]; chop($reportColor); $reportHeader=$reportData[1]; chop($reportHeader); $reportHeader=~s/</\<\;/g; $reportHeader=~s/::/\n/g; $reportSequence=$reportData[2]; chop($reportSequence); $reportSort=$reportData[3]; chop($reportSort); $reportOrder=$reportData[4]; chop($reportOrder); $reportLines=$reportData[5]; chop($reportLines); $reportForm=$reportData[6]; chop($reportForm); $searchHeader=$reportData[7]; chop($searchHeader); $searchHeader=~s/</\<\;/g; $searchHeader=~s/::/\n/g; $searchInfo=$reportData[8]; chop($searchText); print " <SCRIPT> nav=navigator.userAgent\; if (nav.indexOf(\'MSIE 3\')>0) {IE3=true} else {IE3=false}\; function clearSequence (s) { if (IE3) { alert(\"Sorry, MSIE 3 does not support dynamic lists. \\nYou must use MSIE 4+ or Netscape 3+ to use this function\")\; } else { s.options.length=0\; document.form1.seqnums.value=\"\"\; }\; }\; function setseq(L,R) { if (IE3) { alert(\"Sorry, MSIE 3 does not support dynamic lists. \\nYou must use MSIE 4+ or Netscape 3+ to use this function\")\; } else { var len=R.options.length\; R.options.length++\; i=L.selectedIndex\; R.options[len].text=L.options[i].text\; R.options[len].value=i\; setnums(R)\; } }\; function setnums(s) { var len=s.options.length\; result=\"\"\; for (i=0;i<len;i++) { result+=s.options[i].value+\":\" }\; document.form1.seqnums.value=result\; }\; </SCRIPT> <BODY BGCOLOR=\"BEIGE\" onLoad=\"setnums(document.form1.sequence)\"> <h3 align=center>Customize the color, sequence, and sort order of user search results</h3> <FORM NAME=\"form1\" ACTION=\"$cgilocation\" METHOD=POST> <B>Background Color:</B><BR> Enter a standard color or hex triplet<BR> \<\;BODY BGCOLOR=\" <INPUT TYPE=TEXT NAME=\"color\" VALUE=\"$reportColor\">\"><P> <P> <B>Header for search page:</B><BR> <I>This will go at the top of the search input form that users come to first.</I><BR> Enter any header text and/or images using HTML code:<BR> <TEXTAREA NAME=\"searchHeader\" COLS=60 ROWS=8 WRAP=VIRTUAL>$searchHeader</TEXTAREA><P> <B>Include default search instructions on Search Page?</B> <INPUT TYPE=CHECKBOX NAME=searchInfo VALUE=1"; if ($searchInfo==1) {print " CHECKED"}; print "> <P> <B>Header for results page:</B><BR> <I>This will go at the top of the search results table.</I><BR> Enter any header text and/or images using HTML code:<BR> <TEXTAREA NAME=\"header\" COLS=60 ROWS=8 WRAP=VIRTUAL>$reportHeader</TEXTAREA><P> <B>Sequence of Fields:</B><BR> Click the fields in the left box in the sequence you wish <BR> to display them in the user search results table.<BR> You may leave out fields which you wish to hide from users<BR> <table border=0 cellpadding=10><tr><th>Avaliable fields<th>Report Columns (left to right)<tr><td align=center> <SELECT NAME=\"fields\" size=$len width=200 onChange=\"setseq(this,form.sequence)\">"; foreach (@fields) {print "<OPTION>$_\n";}; print " </SELECT> <td align=center><SELECT NAME=\"sequence\" size=$len width=200>"; @seq=split(/:/,$reportSequence); foreach (@seq) { print "<OPTION VALUE=\'$_\'>$fields[$_]\n"; }; print " </SELECT><tr><td><td align=center> <input type=button value=\"Clear Sequence\" onClick=\"clearSequence(form.sequence)\"></table></table><P> <input type=hidden name=\"seqnums\" value=\"\"> <B>Sort by:<br></b>Choose the field by which you wish to sort</B> <SELECT NAME=\"sort\" size=1>"; $i=1; print "<OPTION VALUE=\"0\">-- not sorted --\n"; foreach (@fields) { print "<OPTION VALUE=\"$i\""; if ($reportSort == $i) {print " SELECTED";}; print ">$_\n"; $i++; }; print "</SELECT>"; print "<B>Sort Sequence:</B><SELECT NAME=\"order\"><OPTION VALUE=0>Ascending"; print "<OPTION VALUE=1 "; if ($reportOrder==1) {print "SELECTED"} print ">Descending</SELECT>"; print "<B>Number of results per page</B> <INPUT TYPE=text NAME=\"numrows\" SIZE=3 VALUE=\"$reportLines\"><P> <B>Include \"view\" button?</B> <INPUT TYPE=checkbox NAME=\"form\""; if ($reportForm==1) {print " CHECKED"}; print "><BR> The view button appears next to each record in the user search results. It displays the current record in a columnar form. <P> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Modify Pages\"><BR> <A HREF=\'$cgilocation?cgifunction=admin\'>Return to Administration Page</A> </FORM>"; print " <A HREF=\"$searchpage\">Test your modifications on the User Search Page</A>"; }; #*******END REPORT PAGE SUBROUTINE********** #********BEGIN MEMBERADD SUBROUTINE************** sub memberadd { &memberpass; open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; @value=(); $fcount=1; shift(@fields); foreach (@fields) { chop($_) if (/\n$/); $value[$fcount]=$user_data{$_}; $fcount++; }; $value[0]=time(); #pop(@value); #** Remove cgifunction from @value array ** #if ($user_data{pagenum}>0) {pop(@value)}; #** remove pagenum from @value array foreach (@value) { $_=~s/\r/\n/g; $_=~s/\n\n/\n/g; $_=~s/\n/<BR>/g; }; print " <HEAD><TITLE>Webdata Entry Added</TITLE></HEAD> <BODY BGCOLOR=\"BEIGE\"><H1>"; #******* Remove delimeter characters and leading spaces********* foreach $item (@value) { $item=~s/^( *)//ge; # remove leading spaces from entries $item=~s/::/'::'/ge; # replace delimiting character from entries }; #****Check to see if entry is already used**** open(READLOG,"<$logfile"); @entries = <READLOG>; $unique="true"; foreach $line (@entries) { @fields = split(/::/,$line); if ($fields[0] eq $value[0]) { $unique="false"; }; }; close READLOG; #********Add values to $logfile file******************* if($unique eq "true") { push(@value,"$userid"); open(LOGFILE,">>$logfile"); $line=join("::",@value); print LOGFILE ("$line\n"); close(LOGFILE); print "Your entry has been added.</H1><P>"; } else { print "<font color=\"red\">"; print "That ID key has already been used. Click 'Search' to find or change it. Do not use Reload and Repost-Data</h1></font>"; }; #****RETURN TO MAINTENANCE SCREEN**** print "<A HREF=\"javascript:history.go(-1)\"> Return to previous page</h1> "; }; #*********END MEMBER ADD SUBROUTINE******************** #****BEGIN MEMBER PAGE SUBROUTINE sub memberpage { &memberpass; print "<SCRIPT>document.cookie=\"$cookie\"</SCRIPT>"; print " <HEAD><TITLE>Members Admin Page</TITLE></HEAD> <BODY BGCOLOR=\"beige\" <H1 align=center> Members Administration Page </H1> <form name=\"form1\" action=\"$cgilocation\" method=post> <input type=hidden name=\"ID\"> <TABLE BORDER=0> "; @fields=(); @types=(); open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); shift(@types); foreach $field (@fields) { &gettype($types[$ftcount]); chop($field); if ($type eq "text") { print "<TR><TD><B>$field<TD><input type=$type name=\"$field\" size=$typesize>\n"; }; if ($type eq "checkbox") { print "<TR><TD><B>$field<TD><input type=checkbox name=\"$field\" value=\"yes\">\n"; }; if ($type eq "list") { print "<TR><TD><B>$field<TD><SELECT NAME=\"$field\" SIZE=1>\n"; print "<OPTION VALUE=\"\">\n"; foreach (@typelistvals) { print "<OPTION>$_\n"; }; print "</SELECT>\n"; }; if ($type eq "comment") { print "<TR><TD><B>$field<TD><TEXTAREA NAME=\"$field\" COLS=60 ROWS=$typerows></TEXTAREA>\n"; }; $ftcount++; }; print " <!-- Do not change the values of the submit buttons --> </TABLE> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"add\"> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Search/modify\"> <INPUT TYPE=RESET VALUE=\"Clear Form\"><P> </FORM> <h2> Click \'Add\' to add a record to the database. <P>To modify or delete a record: Search for the record, then click on the record in the search results window.</h2> <A HREF=\"$homepage\"> Return to home page</A> "; }; #****END MEMBER PAGE SUBROUTINE #*****BEGIN ADD MEMBER SUBROUTINE sub addmember { if ($value[0] eq "admin") { print "<SCRIPT>alert(\'admin is a reserved name\')</SCRIPT>"; &members; exit; }; open(FILE,"<$members"); @members=<FILE>; close FILE; foreach (@members) { ($user,$pass)=split(/::/); if ($value[0] eq $user) { print "<SCRIPT>\n"; print "alert(\'That name is already used. Please choose another\')\n"; print "</SCRIPT>"; &members; exit; }; }; $pass=crypt($value[1],7); $line="$value[0]::$pass\n"; open(FILE,">>$members"); print FILE ("$line"); close FILE; &members; }; #****END ADD MEMBER SUBROUTINE #*****BEGIN DELETE MEMBER SUBROUTINE sub deletemember { open(FILE,"<$members")||die "Could not open $members"; @oldlist=<FILE>; close FILE; foreach (@oldlist) { ($user,$pass)=split(/::/); if ($user ne $user_data{member}) {push(@newlist,$_)}; }; open(FILE,">$members")||die "Could not open $members"; print FILE (@newlist); close FILE; &members; }; #****END DELETE MEMBER SUBROUTINE #****BEGIN ADD/REMOVE MEMBERS SUBROUTINE sub members { &checkpass; print "<body bgcolor=beige>\n<h1 align=center>Members</h1>\n"; open(FILE,"<$members"); @members=<FILE>; close FILE; $len=@members; if ($len==0) { print "No members have been created yet\n"; } else { print "<FORM ACTION=\"$cgilocation\" METHOD=POST>\n"; print "<SELECT NAME=\"member\" size=$len>\n"; foreach (@members) { ($user,$pass)=split(/::/); print "<OPTION>$user\n"; }; print "</SELECT><BR>"; print "<INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Delete Member\">\n"; print "</FORM>"; }; print " <HR><CENTER><B>Add A Member</B></CENTER> <TABLE BORDER=0> <FORM ACTION=\"$cgilocation\" METHOD=POST> <TR><TD><B>User Name</B><TD><INPUT TYPE=TEXT NAME=\"username\" SIZE=20><BR> <TR><TD><B>Password</B><TD><INPUT TYPE=TEXT NAME=\"password\" SIZE=20><BR> </TABLE> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Add Member\"> </FORM><BR><A HREF=\"$cgilocation?cgifunction=admin\">Return to Administration Page</A> "; }; #****END ADD/REMOVE MEMBERS SUBROUTINE #*******BEGIN NEXTPREV SUBROUTINE***** # THIS SUBROUTINE REPLACES THE PAGENUM CRITERIA, THEN # RUNS THE USERSEARCH ROUTINE sub nextprev { if ($user_data{cgifunction} eq "Next Page") {$n=1} else {$n=-1}; $p=$user_data{pagenum}+$n; $q=$user_data{query}; $replace="pagenum=$p"; $find="pagenum=$user_data{pagenum}"; $q=~s/$find/$replace/; #EMPTY VALUE AND USER_DATA ARRAYS BEFORE RUNNING READPARSE @value=(); %user_data=(); &readparse($q); &usersearch if ($user_data{cgifunction} eq "Search"); &adminsearch if ($user_data{cgifunction} eq "Search/modify"); }; #*******END NEXTPREV SUBROUTINE******* #*******BEGIN RENAMEFIELD SUBROUTINE*** sub renameField { &checkpass; $select = $value[0]; $select++; open(FIELDS,"<$fieldnames"); @fields=<FIELDS>; close FIELDS; $newfield="$value[1]\n"; $fields[$select]=$newfield; open(RESULT,">$fieldnames"); print RESULT (@fields); close RESULT; #****RETURN TO FIELD MODIFY SCREEN**** @value=(); &fieldmod; }; #*******END RENAME FIELD SUBROUTINE**** #*******BEGIN INSERTFIELD SUBROUTINE**** sub insertField { &checkpass; $select = $value[0]; $select++; open(FIELDS,"<$fieldnames"); @fields=<FIELDS>; close FIELDS; $numfields=@fields; $newfield="$fields[$select]$value[1]\n"; $fields[$select]=$newfield; open(RESULT,">$fieldnames"); print RESULT (@fields); close RESULT; open(RECORDS,"<$logfile"); @records = <RECORDS>; close RECORDS; foreach (@records) { chop($_); @linedata=split(/::/,$_); $newdata="$linedata[$select]::"; $linedata[$select]=$newdata; $newline=join('::',@linedata); $_="$newline\n"; }; open(RECORDS,">$logfile"); print RECORDS (@records); close RECORDS; #****RETURN TO FIELD MODIFY SCREEN**** @value=(); &fieldmod; }; #*******END INSERTFIELD SUBROUTINE****** #*******BEGIN DELETEFIELD SUBROUTINE**** sub deleteField { &checkpass; $select = $value[0]; $select++; open(FIELDS,"<$fieldnames"); @fields=<FIELDS>; close FIELDS; foreach $field (@fields) { if ($field ne $fields[$select]) { push(@result,$field); } } open(FIELDS,">$fieldnames"); print FIELDS (@result); close FIELDS; open(RECORDS,"<$logfile"); @records=<RECORDS>; close RECORDS; foreach $record (@records) { chop($record); @linedata=split(/::/,$record); @newline=(""); $count=0; foreach $item (@linedata) { if ($count != $select) { push(@newline,$item); }; $count++; }; shift(@newline); $record = join('::',@newline)."\n"; }; open(RECORDS,">$logfile"); print RECORDS (@records); close RECORDS; #****RETURN TO FIELD MODIFY SCREEN**** @value=(); &fieldmod; }; #*******END DELETEFIELD SUBROUTINE****** #*******BEGIN FIELDMOD SUBROUTINE******** sub fieldmod { &checkpass; open(FIELDS,"<$fieldnames"); @fields=<FIELDS>; close FIELDS; shift(@fields); $num=@fields; $num++; print " <HEAD> <TITLE>Webdata Modify Fields</TITLE> <SCRIPT> function insert(s) { newfield=prompt(\"New Field Name:\",\"\")\; if (!newfield) {return}\; newtype=\"\"\; while ((newtype!=\"text\")&&(newtype!=\"checkbox\")&&(newtype!=\"list\")&&(newtype!=\"comment\")) { newtype=prompt(\"Enter text, checkbox, comment, or list\")\; if(!newtype) {return}\; }\; if (newtype==\"text\") { newval=\":\"+prompt(\"Enter how many characters:\") if (newval==\":null\") {return}\; }\; if (newtype==\"checkbox\") {newval=\"\"}\; if (newtype==\"list\") { newval=\":\"+prompt(\"Enter each value in list with a comma in between:\") if(newval==\":null\") {return}\; }\; if (newtype==\"comment\") { newval=\":\"+prompt(\"Enter how many rows high you would like the comment box:\")\; if(newval==\":null\") {return}\; }\; document.form2.newFieldName.value=newfield+\"::\"+newtype+newval\; document.form2.selectedField.value=s.selectedIndex\; document.form2.cgifunction.value=\"insertField\"\; document.form2.submit()\; } function del(s) { if (s.selectedIndex<0) {return} message=\"Are you sure you want to delete the selected field?\\n\"\; message+=\" Any data contained in that field will be destroyed.\"\; if(confirm(message)) { document.form2.selectedField.value=s.selectedIndex\; document.form2.cgifunction.value=\"deleteField\"\; document.form2.submit()\; } } function rename(s) { oldfield=s.options[s.selectedIndex].text\; del1=oldfield.indexOf(\'::\')\; oldname=oldfield.substring(0,del1)\; oldfield=oldfield.substring(del1+2,9999)\; del1=oldfield.indexOf(\':\')\; if (del1==-1) {del1=9999}\; oldtype=oldfield.substring(0,del1)\; oldfield=oldfield.substring(del1+1,9999)\; oldvalue=oldfield.substring(0,9999)\; newfield=prompt(\"New Field Name:\",oldname)\; if (!newfield) {return}\; newtype=\"\"\; while ((newtype!=\"text\")&&(newtype!=\"checkbox\")&&(newtype!=\"list\")&&(newtype!=\"comment\")) { newtype=prompt(\"Enter text, checkbox, comment, or list\",oldtype)\; if(!newtype) {return}\; }\; if (newtype!=oldtype) {oldvalue=\"\"}\; if (newtype==\"text\") { newval=\":\"+prompt(\"Enter how many characters:\",oldvalue) if (newval==\":null\") {return}\; }\; if (newtype==\"checkbox\") {newval=\"\"}\; if (newtype==\"list\") { newval=\":\"+prompt(\"Enter each value in list with a comma in between:\",oldvalue) if(newval==\":null\") {return}\; }\; if (newtype==\"comment\") { newval=\":\"+prompt(\"Enter how many rows high you would like the comment box:\",oldvalue)\; if(newval==\":null\") {return}\; }\; document.form2.newFieldName.value=newfield+\"::\"+newtype+newval\; document.form2.selectedField.value=s.selectedIndex\; document.form2.cgifunction.value=\"renameField\"\; document.form2.submit()\; } function admin() { document.form2.cgifunction.value=\"admin\"\; document.form2.submit()\; } function clear() { document.form1.list.selectedIndex=-1; } </SCRIPT> </HEAD> <BODY BGCOLOR=\"beige\"> <H1>Modify Field List</H1> <FORM NAME=\"form1\" ACTION=\"$cgilocation\" METHOD=POST> <TABLE BORDER=0><TR><TD> <SELECT NAME=\"list\" SIZE=$num> "; foreach $field (@fields) { chop($field); print "<OPTION VALUE=\"$field\">$field\n"; }; print " </SELECT> <TR><TD> <P><INPUT TYPE=\"BUTTON\" VALUE=\"INSERT FIELD BELOW SELECTION\" onClick=\"insert(form.list)\"><BR> <INPUT TYPE=\"BUTTON\" VALUE=\"DELETE SELECTED FIELD\" onClick=\"del(form.list)\"><BR> <INPUT TYPE=\"BUTTON\" VALUE=\"REDEFINE SELECTED FIELD\" onClick=\"rename(form.list)\"> </TABLE> </FORM> To create a text box: Click Insert or Redefine field. Enter the field\'s name in the first prompt box. Enter the word \"text\" in the second prompt box. Enter the SIZE in number of characters for the new text box.<P> To create a checkbox: Click Insert or Redefine field. Enter the field\'s name in the first prompt box. Enter the word \"checkbox\" in the second prompt box. That's it.<P> To create a selection list: Click Insert or Redefine field. Enter the field\'s name in the first prompt box. Enter the word \"list\" in the second prompt box. In the third prompt box, enter the list of values, seperated by a comma without spaces around the comma. For example.<BR><B>Fire Engine Red,Lemon Yellow,Medium Blue,Salmon,Crimson,Ash White</B><P> To create a textarea box for comments: Click Insert or Redefine field. Enter the field\'s name in the first prompt box. Enter the word \"comment\" in the second prompt box. In the third box, enter the number of rows high you wish to make your comment box. It will have a width of 60 characters. <P> <A HREF=\"javascript:admin()\">Return to Administration Page</A> <P> To insert a field at the <i>top</i> of the list, do not select anything.<BR> <A HREF=\"javascript:clear()\"> Click here to clear the selection</A> <FORM NAME=\"form2\" ACTION=\"$cgilocation\" METHOD=POST> <INPUT TYPE=HIDDEN NAME=\"selectedField\"> <INPUT TYPE=HIDDEN NAME=\"newFieldName\"> <INPUT TYPE=HIDDEN NAME=\"cgifunction\"> "; }; #*******END FIELDMOD SUBROUTINE********** #*******BEGIN USER SUBROUTINE************* sub user { open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); shift(@types); open(REPORT, "<$reportdata"); @reportData=<REPORT>; close REPORT; $reportColor=$reportData[0]; chop($reportColor); $searchHeader=$reportData[7]; chop($searchHeader); $searchHeader=~s/\<\;/</g; $searchHeader=~s/::/\n/g; $searchInfo=$reportData[8]; chop($searchInfo); print " <HEAD><TITLE>Database Search</TITLE></HEAD> <BODY bgcolor=\"$reportColor\"> $searchHeader "; if ($searchInfo==1) { print " <font size=3> Click \"Clear Form\" then \"Search\" to see all records.<BR> Enter text in any field to restrict the search to only those records which <I>CONTAIN</I> your text in that field.<P> For numeric comparisons, begin with \>\;, \<\;, \>\;=, or \<\;=<BR> To find a range, type <TT><B>between</B> lowvalue <B>and</B> highvalue.</TT><BR> Do not use commas or dollar signs in numeric searches.<BR> Use \"and\" & \"or\" for complex searches.</font> "; }; print "<FORM NAME=\"form1\" ACTION=\"$cgilocation\" method=\"post\"> <TABLE> "; $ftcount=0; foreach $field (@fields) { &gettype($types[$ftcount]); chop($field); if ($type eq "text") { print "<TR><TD><B>$field<TD><input type=$type name=\"$field\" size=$typesize>\n"; }; if ($type eq "checkbox") { print "<TR><TD><B>$field<TD><input type=checkbox name=\"$field\" value=\"yes\">\n"; }; if ($type eq "list") { print "<TR><TD><B>$field<TD><SELECT NAME=\"$field\" SIZE=1>\n"; print "<OPTION VALUE=\"\">\n"; foreach (@typelistvals) { print "<OPTION>$_\n"; }; print "</SELECT>\n"; }; if ($type eq "comment") { print "<TR><TD><B>$field<TD><TEXTAREA NAME=\"$field\" COLS=60 ROWS=$typerows></TEXTAREA>\n"; }; $ftcount++; }; print "</TABLE> <BR> <input type=submit name=\"cgifunction\" value=\"Search\"> <!--FLAG3--> <input type=submit name=\"cgifunction\" value=\"Add\"> <!--FLAG1--> <input type=reset value=\"Clear Form\"> </FORM> "; }; #*******END USER SUBROUTINE*************** #********BEGIN ADD SUBROUTINE************** sub add { &memberpass; #<!--FLAG2--> open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; $fcount=1; shift(@fields); foreach (@fields) { chop($_) if (/\n$/); $value[$fcount]=$user_data{$_}; $fcount++; }; $value[0]=time(); #pop(@value); #** Remove cgifunction from @value array ** #if ($user_data{pagenum}>0) {pop(@value)}; #** remove pagenum from @value array foreach (@value) { $_=~s/\r/\n/g; $_=~s/\n\n/\n/g; $_=~s/\n/<BR>/g; }; print " <HEAD><TITLE>Webdata Entry Added</TITLE></HEAD> <BODY BGCOLOR=\"BEIGE\"><H1>"; #******* Remove delimeter characters and leading spaces********* foreach $item (@value) { $item=~s/^( *)//ge; # remove leading spaces from entries $item=~s/::/'::'/ge; # replace delimiting character from entries }; #****Check to see if entry is already used**** open(READLOG,"<$logfile"); @entries = <READLOG>; $unique="true"; foreach $line (@entries) { @fields = split(/::/,$line); if ($fields[0] eq $value[0]) { $unique="false"; }; }; close READLOG; #********Add values to $logfile file******************* if($unique eq "true") { push(@value,"admin"); open(LOGFILE,">>$logfile"); $line=join("::",@value); print LOGFILE ("$line\n"); close(LOGFILE); print "Your entry has been added.</H1><P>"; } else { print "<font color=\"red\">"; print "That ID key has already been used. Click 'Search' to find or change it. Do not use Reload and Repost-Data</h1></font>"; }; #****RETURN TO MAINTENANCE SCREEN**** print "<A HREF=\"javascript:history.go(-1)\"> Return to previous page</h1> "; }; #*********END ADD SUBROUTINE******************** #**********BEGIN SEARCH SUBROUTINE****************** sub adminsearch { &memberpass; pop(@value); #** Remove cgifunction from @value array ** #shift(@value); #** Remove hidden ID from top of @value array ** if ($userid ne "admin") {push(@value,$userid)}; print " <HEAD><TITLE>Webdata Admin Search</TITLE></HEAD> <SCRIPT> function modify(sym) { document.form1.part.value=sym\; document.form1.submit()\; } function goadmin() { document.form1.cgifunction.value=\""; if ($userid eq "admin") { print "admin"; } else { print "memberpage" }; print "\"\; document.form1.submit()\; } function deleteset() { msg=\'This will permanently delete all of\\n\'+ \'the records displayed on the screen. Are you\\n\'+ \'sure that you want to do this?\'\; if (confirm(msg)) { document.form1.cgifunction.value=\"deleteset\"\; document.form1.submit()\; }\; } </SCRIPT>\n <H1 ALIGN=CENTER>Administration Search Page</H1> "; open(LOGFILE,"<$logfile"); @entries = <LOGFILE>; close (LOGFILE); print "<BODY BGCOLOR=\"BEIGE\">\n"; print "<TABLE BORDER=1 bgcolor=\"white\">\n"; open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; $fcount=1; @value=(); shift(@fields); foreach (@fields) { chop($_) if (/\n$/); $value[$fcount]=$user_data{$_}; $fcount++; }; if ($userid ne "admin") {push(@value,$userid)}; shift(@value); $header= "<TR>"; foreach $field (@fields) { $header .= "<TH>$field"; }; print "$header\n"; #***** BEGIN STEPPING THROUGH ALL THE DATA LINES***** #***** PARSE THE DATA ***************** foreach $line (@entries) { @fields = split(/::/,$line); $ID = shift(@fields); # *** IF LINE MATCHES PATTERN *********** $display="true"; $numPairs=@value; for ($i=0;$i<$numPairs;$i++) { if ($value[$i]=~/[0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+/) { $_=$value[$i]; @temp=m/([0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+)/g; $temp[0]=&datetonum($temp[0]); $temp[1]=&datetonum($temp[1]); if (/^([><=]+)/) {$temp3=$1}; $criteria=$temp3.$temp[0]; if (/^between/i) {$criteria="between $temp[0] and $temp[1]"}; if ($fields[$i]=~/[0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+/) { $dataval=&datetonum($fields[$i]); } else { $display="false"; }; } else { $dataval=$fields[$i]; $criteria=$value[$i]; }; $_=$dataval; $criteria=~s/ or /\|/gi; $firstchar=substr($criteria,0,1); $combo="false"; if (!((/$criteria/i)||($criteria eq "")|| ($firstchar eq '<')||($firstchar eq '>')|| ($criteria=~/ and /i))) { $display="false"; }; if ((substr($criteria,0,2) eq '<=')&&($_ > substr($criteria,2,99))) { $combo="true"; $display="false"; }; if ((substr($criteria,0,2) eq '>=')&&($_ < substr($criteria,2,99))) { $combo="true"; $display="false"; }; if (($combo ne "true")&&(substr($criteria,1,1) ne '=')) { if ((substr($criteria,0,1) eq '<')&&($_ >= substr($criteria,1,99))) { $display="false"; }; if ((substr($criteria,0,1) eq '>')&&($_ <= substr($criteria,1,99))) { $display="false"; }; if ($criteria=~/^between.* and /i) { $andpos = index($criteria,'and'); if ($andpos<8) {$display="false";}; $val1 = substr($criteria,7,$andpos); $val2 = substr($criteria,$andpos+4,99); if (($_<$val1)||($_>$val2)) { $display="false"; }; }; if (($criteria=~/ and /i)&&(!($criteria=~/^between/i))) { @cdata=split(/ and /i,$criteria); foreach $citem (@cdata) { if(!(/$citem/i)) {$display="false";}; }; }; }; }; #***** DISPLAY THE LINE **************** if (!$user_data{pagenum}) { $user_data{pagenum}=1; $querystring=~s/cgifunction/pagenum=1\&cgifunction/; }; $pagenum=$user_data{pagenum}; $min=($pagenum-1)*20; $max=$pagenum*20; if ($display eq "true") { $count++; if (($count>$min)&&($count<=$max)) { print "\n<TR>"; foreach $n (@fields) { print "<TD><A HREF=\"javascript:modify(\'$ID\')\">"; if ($n eq "") {$n = ' </A>';}; $n=~s/[\r\n]/<BR>/g; print "$n</A>"; }; }; push(@foundset,$ID); }; }; print "\n</table>\n"; $foundsetstring=join(':',@foundset); print "<form name=\"form1\" action=\"$cgilocation\" method=post>\n"; print "<input name=\"part\" type=hidden>\n"; print "<input name=\"password\" type=hidden>\n"; print "<input name=\"cgifunction\" type=hidden value=\"maintenance\">\n"; print "<input name=\"foundset\" type=hidden value=\"$foundsetstring\">\n"; print "</form>\n"; if ($count>0) { print "<h2>Click on an entry to modify or delete it. </h2> <form><input type=button value=\"Delete All $count Found Records\" onClick=\"deleteset()\"></form><BR>"; #BEGIN NEXT/PREV BUTTONS $min++; if ($max>$count) {$max=$count}; print " <B>Results $min - $max of $count</B> <table border=0 cellspacing=10 cellpadding=0><TR><TD> "; if ($min>1) {print " <FORM ACTION=\"$cgilocation\" METHOD=POST> <INPUT TYPE=HIDDEN NAME=\"query\" VALUE=\"$querystring\"> <INPUT TYPE=HIDDEN NAME=\"pagenum\" VALUE=\"$pagenum\"> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" value=\"Previous Page\"> </FORM> "}; if ($max<$count) {print " <TD> <FORM ACTION=\"$cgilocation\" METHOD=POST> <INPUT TYPE=HIDDEN NAME=\"query\" VALUE=\"$querystring\"> <INPUT TYPE=HIDDEN NAME=\"pagenum\" VALUE=\"$pagenum\"> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" value=\"Next Page\"> </FORM> "}; print "</table>"; #END NEXT/PREV BUTTONS } else { print "<B>No records were found</B><P>"; }; #CREATE LINKS TO ANY PAGENUMBER print "<BR>Go to page\:"; $numpages=int($count/20); $myquery=$querystring; if ($count/20>$numpages) {$numpages++;}; for ($i=1;$i<=$numpages;$i++) { $myquery=~s/pagenum=[0-9]*/pagenum=$i/; print "<A HREF=\"$cgilocation\?$myquery\">$i</A> "; }; print "<BR><A HREF=\"javascript:goadmin()\">Return to Administration Page</A>\n"; print "<P><A HREF=\"$homepage\"> Return to home page</A>\n"; }; #*********END OF SEARCH SUBROUTINE************ #**********BEGIN USERSEARCH SUBROUTINE****************** #*****Same as Search except the results**************** #*****Do not link to maintenance *************** # sub usersearch { &checkpass; #<!--FLAG4--> pop(@value); #** Remove cgifunction from @value array ** pop(@value); #** Remove pagnum from @value array ** shift(@value); #remove ID from @value array ** open(LOGFILE,"<$logfile"); @entries = <LOGFILE>; close (LOGFILE); open(REPORT, "<$reportdata"); @reportData=<REPORT>; close REPORT; $reportColor=$reportData[0]; chop($reportColor); $reportHeader=$reportData[1]; chop($reportHeader); $reportHeader=~s/\<\;/</g; $reportHeader=~s/::/\n/g; $reportSequence=$reportData[2]; chop($reportSequence); @sequence=split(/:/,$reportSequence); $reportSort=$reportData[3]; chop($reportSort); $reportOrder=$reportData[4]; chop($reportOrder); $reportLines=$reportData[5]; chop($reportLines); $reportForm=$reportData[6]; chop($reportForm); #PARSE/SORT ROUTINE if ($reportSort>0) { #...populate sorting array $sortcount=0; $textsort="false"; foreach (@entries) { @data=split(/::/); $val=$data[$reportSort]; if ($val=~/^[0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]*$/) {$val=&datetonum($val)}; if ($val=~/[a-zA-Z]/) {$textsort="true"}; $sortarray{$sortcount}=$val; $sortcount++; }; if ($reportOrder==1) {$bottom="\$a";$top="\$b"} else {$top="\$a";$bottom="\$b"}; if ($textsort eq "true") {$oper="cmp"} else {$oper="<=>"}; eval('@sortarray=sort {$sortarray{'.$top.'} '.$oper.' $sortarray{'.$bottom.'}} keys %sortarray;'); foreach (@sortarray) {push(@temp,$entries[$_])}; @entries=@temp; }; print "<HEAD><TITLE>Search Results page $user_data{pagenum}</TITLE></HEAD>"; print "<BODY BGCOLOR=\"$reportColor\">\n"; print "$reportHeader\n"; if (!$user_data{pagenum}) { $user_data{pagenum}=1; $querystring=~s/cgifunction/pagenum=1\&cgifunction/; }; $pagenum=$user_data{pagenum}; print "<FORM><TABLE BORDER=1 bgcolor=\"white\">\n"; open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); #POPULATE @VALUE INDEPENDENT OF SEQUENCE $fcount=0; foreach (@fields) { chop($_); $value[$fcount]=$user_data{$_}; $fcount++; }; $header= "<TR>"; if ($reportForm==1) {$header.="<TH>";}; foreach (@sequence) { $header .= "<TH>$fields[$_]"; }; print "$header\n"; #***** BEGIN STEPPING THROUGH ALL THE DATA LINES***** #***** PARSE THE DATA ***************** $date=0; foreach $line (@entries) { @fields = split(/::/,$line); $id=$fields[0]; shift(@fields); #**Remove hidden key from view** pop(@fields); #**Remove membername from view** # *** IF LINE MATCHES PATTERN *********** $display="true"; $numPairs=@value; for ($i=0;$i<$numPairs;$i++) { if ($value[$i]=~/[0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+/) { $_=$value[$i]; @temp=m/([0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+)/g; $temp[0]=&datetonum($temp[0]); $temp[1]=&datetonum($temp[1]); if (/^([><=]+)/) {$temp3=$1}; $criteria=$temp3.$temp[0]; if (/^between/i) {$criteria="between $temp[0] and $temp[1]"}; if ($fields[$i]=~/[0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+/) { $dataval=&datetonum($fields[$i]); } else { $display="false"; }; } else { $dataval=$fields[$i]; $criteria=$value[$i]; }; $_=$dataval; $criteria=~s/ or /\|/gi; $firstchar=substr($criteria,0,1); $combo="false"; if (!((/$criteria/i)||($criteria eq "")|| ($firstchar eq '<')||($firstchar eq '>')|| ($criteria=~/ and /i))) { $display="false"; }; if ((substr($criteria,0,2) eq '<=')&&($_ > substr($criteria,2,99))) { $combo="true"; $display="false"; }; if ((substr($criteria,0,2) eq '>=')&&($_ < substr($criteria,2,99))) { $combo="true"; $display="false"; }; if (($combo ne "true")&&(substr($criteria,1,1) ne '=')) { if ((substr($criteria,0,1) eq '<')&&($_ >= substr($criteria,1,99))) { $display="false"; }; if ((substr($criteria,0,1) eq '>')&&($_ <= substr($criteria,1,99))) { $display="false"; }; if ($criteria=~/^between.* and /i) { $andpos = index($criteria,'and'); if ($andpos<8) {$display="false";}; $val1 = substr($criteria,7,$andpos); $val2 = substr($criteria,$andpos+4,99); if (($_<$val1)||($_>$val2)) { $display="false"; }; }; if (($criteria=~/ and /i)&&(!($criteria=~/^between/i))) { @cdata=split(/ and /i,$criteria); foreach $citem (@cdata) { if(!(/$citem/i)) {$display="false";}; }; }; }; }; #***** DISPLAY THE LINE **************** $min=($pagenum-1)*$reportLines; $max=$pagenum*$reportLines; if ($display eq "true") { $count++; if (($count>$min)&&($count<=$max)) { print "\n<TR>"; if ($reportForm==1) { print "<TD><input type=button value=\"view\""; print " onClick=\"viewform($id,\'$querystring\')\">"; }; #***** BEGIN DISPLAY DATA LOOP ******* foreach (@sequence) { $n=$fields[$_]; $n=~s/\r/<BR>/g; if ($n eq "") {$n=' ';}; $n=~s/^([0-9a-zA-Z_\-\.\~]+\@[0-9a-zA-Z_\-\.\~]+\.[0-9a-zA-Z_\-\.\~]+)/<A HREF=mailto:$1>$1<\/A>/; if ($n=~/^([^ ]+\.(gif|jpg))$/) {$n="<IMG SRC=$1>"} else {$n=~s/^(http[^ ]+)/<A HREF=$1>$1<\/A>/;}; print "<TD>$n"; }; #***** END DISPLAY DATA LOOP ********* }; }; }; print "\n</table></form>\n"; if ($count>0) { print " <SCRIPT LANGUAGE=JavaScript> function viewform(id,q) { document.vf.id.value=id\; document.vf.query.value=q\; document.vf.submit()\; } </SCRIPT> <FORM NAME=\"vf\" ACTION=\"$cgilocation\" METHOD=POST> <INPUT TYPE=HIDDEN NAME=\"id\"> <INPUT TYPE=HIDDEN NAME=\"query\"> <INPUT TYPE=HIDDEN NAME=\"cgifunction\" VALUE=\"form\"> </FORM>\n"; $min++; if ($max>$count) {$max=$count}; print " <B>Results $min - $max of $count</B> <table border=0 cellspacing=10 cellpadding=0><TR><TD> "; if ($min>1) {print " <FORM ACTION=\"$cgilocation\" METHOD=POST> <INPUT TYPE=HIDDEN NAME=\"query\" VALUE=\"$querystring\"> <INPUT TYPE=HIDDEN NAME=\"pagenum\" VALUE=\"$pagenum\"> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" value=\"Previous Page\"> </FORM> "}; if ($max<$count) {print " <TD> <FORM ACTION=\"$cgilocation\" METHOD=POST> <INPUT TYPE=HIDDEN NAME=\"query\" VALUE=\"$querystring\"> <INPUT TYPE=HIDDEN NAME=\"pagenum\" VALUE=\"$pagenum\"> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" value=\"Next Page\"> </FORM> "}; #CREATE LINKS TO ANY PAGENUMBER print "<TR><TD>Go to page\:"; $numpages=int($count/$reportLines); $myquery=$querystring; if ($count/$reportLines>$numpages) {$numpages++;}; for ($i=1;$i<=$numpages;$i++) { $myquery=~s/pagenum=[0-9]*/pagenum=$i/; print "<A HREF=\"$cgilocation\?$myquery\">$i</A> "; }; } else { print "<B>No results were found.</B><P>" }; print "<TD><A HREF=\"$searchpage\"><B>Search Again</B></A>\n"; print "<TD><A HREF=\"$homepage\"> <B>Return to home page</B></A>\n</TABLE>"; }; #*********END OF USERSEARCH SUBROUTINE************ #*********BEGIN MAINTENANCE SUBROUTINE******** sub maintenance { &memberpass; pop(@value); open(READLOG,"<$logfile"); @entries = <READLOG>; close READLOG; foreach $line (@entries) { @fields = split(/::/,$line); if ($fields[0] eq $value[0]) { print " <SCRIPT> function del() { if (confirm(\"Are you sure you want to delete this entry?\")) { document.form1.cgifunction.value=\"delete\"\; document.form1.submit()\; }} function modify() { document.form1.cgifunction.value=\"modify\"\; document.form1.submit()\; } function datecheck(cell) { text=cell.value\; slash=text.lastIndexOf(\"/\")\; year=parseInt(text.substring(slash+1,99))\; if (year<=50) {year=year+2000}\; if ((year>50)&&(year<=99)) {year=year+1900}\; result = text.substring(0,slash+1)+year\; cell.value=result\; } function goadmin() { document.form1.cgifunction.value=\"admin\"; document.form1.submit()\; } </SCRIPT> <HEAD><TITLE>Modify or delete record</TITLE></HEAD> <BODY BGCOLOR=\"beige\"> <H1 align=center> Maintenance Page </H1> <form name=\"form1\" action=\"$cgilocation\" method=post> <TABLE BORDER=0> "; @fields=(); open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); shift(@types); open(READLOG,"<$logfile"); @entries = <READLOG>; close READLOG; foreach $entry (@entries) { @parsed = split(/::/,$entry); if ($parsed[0] eq $value[0]) {@data = @parsed}; }; $num = @fields; print "<TR><TD><B>ID<TD><input type=hidden name=\"ID\" value=\"$data[0]\"><B>$data[0]\n"; shift(@data); $ftcount=0; foreach $field (@fields) { $data[$ftcount]=~s/\"/\"\;/g; &gettype($types[$ftcount]); chop($field); if ($type eq "text") { print "<TR><TD><B>$field<TD><input type=$type name=\"$field\" size=$typesize value=\"$data[$ftcount]\">\n"; }; if ($type eq "checkbox") { print "<TR><TD><B>$field<TD><input type=$type name=\"$field\" value=\"yes\""; if ($data[$ftcount] eq "yes") {print " CHECKED"}; print ">"; }; if ($type eq "list") { print "<TR><TD><B>$field<TD><SELECT NAME=\"$field\" SIZE=1>\n"; print "<OPTION VALUE=\"\">\n"; foreach (@typelistvals) { print "<OPTION"; if ($_ eq $data[$ftcount]) {print " SELECTED"}; print ">$_\n"; }; print "</SELECT>\n"; }; if ($type eq "comment") { $data[$ftcount]=~s/<BR>/\n/g; print "<TR><TD><B>$field<TD><TEXTAREA NAME=\"$field\" COLS=60 ROWS=$typerows>$data[$ftcount]</TEXTAREA>\n"; }; $ftcount++; }; print " <TR><TD colspan=4><input type=button value=\"modify\" onClick=\"modify()\"> <input type=button value=\"Delete\" onClick=\"del()\"> <input type=hidden name=\"cgifunction\"> </TABLE></FORM> <h2>Modify will save the record with the new values.<BR>Delete will remove the record from the table</h2> <A HREF=\"javascript:goadmin()\">Return to Administration Page</A> <P> <A HREF=\"$homepage\"> Return to home page</A> "; }; }; }; #*********END MAINTENANCE SUBROUTINE******* #**** BEGIN MODIFY SUBROUTINE ***** sub modify { &memberpass; pop(@value); open(READLOG,"<$logfile"); @entries = <READLOG>; close READLOG; foreach $item (@value) { $item=~s/^( *)//ge; # remove leading spaces from entries $item=~s/::/'::'/ge; # replace delimiting character from entries $item=~s/\r/\n/g; $item=~s/\n\n/\n/g; $item=~s/\n/<BR>/g; }; @fields=(); @types=(); open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); shift(@types); foreach $line (@entries) { @data=split(/::/,$line); $len=@data; $owner=$data[$len-1]; chop($owner); if ($data[0] eq $value[0]) { if (($owner eq $userid)||($userid eq "admin")) { @value=($data[0]); $fcount=1; foreach (@fields) { chop($_) if (/\n$/); $value[$fcount]=$user_data{$_}; $fcount++; }; foreach $item (@value) { $item=~s/^( *)//ge; # remove leading spaces from entries $item=~s/::/'::'/ge; # replace delimiting character from entries $item=~s/\r/\n/g; $item=~s/\n\n/\n/g; $item=~s/\n/<BR>/g; }; push(@value,$owner); $line=join("::",@value)."\n"; }; }; }; open(PUTLOG,">$logfile"); print PUTLOG (@entries); close PUTLOG; @value=(); if ($userid eq "admin") {&admin} else {&memberpage}; }; #***** END MODIFY SUBROUTINE******* #******* BEGIN DELETE SUBROUTINE ****** sub delete { &memberpass; pop(@value); open(READLOG,"<$logfile"); @entries = <READLOG>; close READLOG; foreach $line (@entries) { @fields=split(/::/,$line); $len=@fields; $owner=$fields[$len-1]; chop($owner); if (($fields[0] ne $value[0])||(($userid ne "admin")&&($userid ne $owner))) { push(@result,$line); }; }; open(PUTLOG, ">$logfile") || die "Content-type: text/html\n\n <BODY BGCOLOR=WHITE><CENTER><H2>Could not open the file $logfile<P> If you have moved the file, you can correct this by changing lines 10 and 11 of the webdata_[database name].cgi script to show the absolute path to the file.<P><P><P></h2> This cgi error was "; print PUTLOG (@result); close PUTLOG; @value=(); if ($userid eq "admin") {&admin} else {&memberpage}; }; #****** END DELETE SUBROUTINE ******* #****** BEGIN CACHE******** sub cache { open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fields=<FIELDS>; close FIELDS; if (&fieldnames($value[0]) eq "true") { $fields[0] = "$value[0]\n"; open(FIELDS,">$fieldnames"); print FIELDS (@fields); close FIELDS; @value=(); &admin; } else { print "incorrect registration"; }; }; #****** END CACHE ******** #****** BEGIN ADMIN SUBROUTINE ****** sub admin { pop(@value); &checkpass; open(FIELDS,"<$fieldnames") || die "Content-type: text/html\n\n <BODY BGCOLOR=WHITE> <h2>Could not open <font color=blue>$fieldnames</font> <P> Make sure the path is correct. If you have moved the data files, you can correct this by changing lines 10 and 11 in the cgi script.<P><BR></P> <P><BR></P><P><BR></P><P><BR></P></h2><font size=3>This cgi error was "; @cache = <FIELDS>; close FIELDS; chop($cache[0]); $cacheval = substr(@cache[0],0,7); if (&fieldnames($cache[0]) ne 'true') { if ($cacheval eq "webdata") { $num=substr(@cache[0],7,99); $num = int(30-((time()-$b)/86400)); @parse=(82,101,103,105,115,116,114,97,116,105,111,110,32,21,101,120,112,105,114,101,100); if($num<0) {foreach (@parse) {print (chr($_))};exit;} print " <font size=4 color=green><B>"; for ($m=0;$m<67;$m++) {print chr(hex($import[$m]))}; print "$num"; for ($m=66;$m<101;$m++) {print chr(hex($import[$m]))}; print "<BR><B>ID Code=$code</B> <A HREF=\"http://www.webteacher.com/webdata/register.htm\"> Click here to Register</A> </B></font> <BR> <form name=\"form3\" action=\"$cgilocation\" method=post> Enter your code:<input name=\"box1\" type=text size=15> <input name=\"cgifunction\" type=hidden value=\"cache\"> <input type=submit value=\"submit registration\"> </form> "; } else { print "There is a problem with the registration code or date log."; exit }; }; print "<script>document.cookie=\"admin=$password\"</script>\n"; print " <HEAD><TITLE>Webdata Admin Page</TITLE></HEAD> <BODY BGCOLOR=\"beige\"> <H1 align=center> Administration Page </H1> <form name=\"form1\" action=\"$cgilocation\" method=post> <TABLE BORDER=0> "; @fields=(); @types=(); open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); shift(@types); foreach $field (@fields) { &gettype($types[$ftcount]); chop($field); if ($type eq "text") { print "<TR><TD><B>$field<TD><input type=$type name=\"$field\" size=$typesize>\n"; }; if ($type eq "checkbox") { print "<TR><TD><B>$field<TD><input type=checkbox name=\"$field\" value=\"yes\">\n"; }; if ($type eq "list") { print "<TR><TD><B>$field<TD><SELECT NAME=\"$field\" SIZE=1>\n"; print "<OPTION VALUE=\"\">\n"; foreach (@typelistvals) { print "<OPTION>$_\n"; }; print "</SELECT>\n"; }; if ($type eq "comment") { print "<TR><TD><B>$field<TD><TEXTAREA NAME=\"$field\" COLS=60 ROWS=$typerows></TEXTAREA>\n"; }; $ftcount++; }; print " </TABLE> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Add\"> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Search/modify\"> <INPUT TYPE=RESET VALUE=\"Clear Form\"><P><HR> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Import data\"> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Export data\"> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Modify fields\"><P> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Members\"> <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Customize Pages\"> </FORM> <h2> Click \'Add\' to add a record to the database. <P>To modify or delete a record: Search for the record, then click on the record in the search results window.</h2> <A HREF=\"$homepage\"> Return to home page</A> "; }; #********END ADMIN SUBROUTINE*************** #********BEGIN IMPORT USER PAGE************** sub import { &checkpass; print " <HEAD><TITLE>Webdata Import Data</TITLE></HEAD> <BODY BGCOLOR=\"BEIGE\"> <h1 align=\"center\">Import a delimeted text file</h1> <h4>A delimeter is a character which is used to tell the database where one field stops, and the next one begins. Most spreadsheet and database programs can save as either comma delimeted or tab delimeted. <P> This program will convert comma or tab delimeted text files to Webdata\'s format, and append the file to your existing database. The imported data file should be in the same sequence as your existing data. Microsoft Excel is a good tool for resequencing data before saving to a delimeted text file. <P></h4> <B>Save the data in your other database program as comma or tab delimeted, then use your FTP program to upload it to your server. You will need the full path name for the file, for example</B><BR> <TT>/user/local/robyoung/webdata/mydata.txt</TT><BR> <P><B><font size=3> What is the full path name of the data file?<BR></font> <form action=\"$cgilocation\" method=\"post\"> <input type=text name=\"filename\" size=60><BR> <font size=3> Is the file comma or tab delimeted?</font> <select name=\"delimeter\" size=1> <option value=\"comma\">comma <option value=\"tab\">tab </select> <input type=hidden name=\"cgifunction\" value=\"import2\"> <INPUT TYPE=SUBMIT VALUE=\"Import\"> </form>"; }; sub fieldnames { if ($_[0] eq crypt($a,$code)) {return 'true'} else {return 0}; }; #********BEGIN IMPORT DATA CONVERSION**************** sub import2 { &checkpass; $file = $user_data{filename}; $dlmtr = $user_data{delimeter}; open(FILE,"<$file") || die print "Could not open file $file"; @file = <FILE>; close FILE; $count=time(); $count=$count-90000000; if ($dlmtr eq 'comma') {$dlmtr=','} else {$dlmtr="\t"}; foreach $line (@file) { $line =~ s/$dlmtr/'::'/ge; chop($line); $line = $count."::$line"."::admin\n"; $count++; }; open(DATA,">>$logfile"); print DATA (@file); close DATA; print "<h1>Data Import complete</h1>"; &admin; }; sub fieldnames { if ($_[0] eq crypt($a,$code)) {return 'true'} else {return 0}; }; #********END IMPORT DATA CONVERSIONS******************* #********BEGIN EXPORT USER PAGE********************** sub export { print " <BODY BGCOLOR=\"BEIGE\"> <H1 ALIGN=\"CENTER\">Export the database to a delimeted text file</H1> <FORM ACTION=\"$cgilocation\" method=POST><B>Please type a full pathname on the server you would like to name the exported file. For example <TT>/user/home/export.txt</TT> <BR>You will then use your FTP program to download the exported data.<P></B> If you have difficulty, check the permissions of that folder. <P> <INPUT TYPE=text NAME=\"path\"><BR> Would you like the file comma or tab delimeted?</font> <select name=\"delimeter\" size=1> <option value=\"comma\">comma <option value=\"tab\">tab </select> <BR> Include field names in first row? <input name=\"fields\" type=checkbox><BR> <input name=\"cgifunction\" type=hidden value=\"export2\"> <input type=submit value=\"Export Data\"> </FORM> "; }; #********END EXPORT USER PAGE********************** #********BEGIN EXPORT DATA CONVERSIONS************ sub export2 { &checkpass; if ($value[1] eq "comma") {$dlmtr=','}; if ($value[1] eq "tab") {$dlmtr="\t"}; open(DATA,"<$logfile"); @data=<DATA>; close DATA; foreach (@data) { @line=split(/::/); shift(@line); pop(@line); $_=join($dlmtr,@line); $_.="\n"; }; if ($user_data{fields} eq "on") { open(FIELDS,"<$fieldnames")||die "Could not open $fieldnames"; @fieldsData=<FIELDS>; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; foreach (@fields) {chop($_)}; shift(@fields); $firstline=join($dlmtr,@fields); unshift(@data,"$firstline\n"); }; open(OUTFILE,">$value[0]"); print OUTFILE (@data); close OUTFILE; open(TEST,"<$value[0]")||die "Could not save $value[0], check privilages"; @test=<TEST>; $len=@test; close TEST; if ($len==0) {print "Could not save $value[0], check privilages"} else {&admin}; }; #******** END BODY************************ # # EACH VALUE IN THE HTML FORM WILL BE CONTAINED IN # THE THE @VALUE ARRAY. sub readparse { if (length($_[0])>0) { $user_string=$_[0] } else { read(STDIN,$user_string,$ENV{'CONTENT_LENGTH'}); }; if (length($ENV{'QUERY_STRING'})>0) {$user_string=$ENV{'QUERY_STRING'};}; if (length($_[0])>0) {$user_string=$_[0]}; $querystring=$user_string; $user_string =~ s/\+/ /g; @name_value_pairs = split(/&/,$user_string); foreach $name_value_pair (@name_value_pairs) { ($keyword,$value) = split(/=/,$name_value_pair); $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge; $keyword =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge; if ($value =~ /\#exec/i) { print "Content-type: text/html\n\n No SSI commands permitted."; exit; }; push(@value, "$value"); if (length($user_data{$keyword})>0) { $user_data{$keyword}.=" or $value"; } else { $user_data{$keyword} = $value; }; }; @import=(54,68,69,73,20,69,73,20,61,20,74,72,69,61,'6C',20,76,65,72,73,69,'6F','6E',20); push(@import,'6F',66,20,57,65,62,64,61,74,61,'2E',20,57,65,62,64,61,74,61,20,77,69,'6C'); $key=896189029; #<!--FLAG5--> eval("\$"."a"."=at98ad01b01ew"); push(@import,'6C',20,73,65,'6C',66,20,64,65,73,74,72,75,63,74,20,69,'6E',20,20,64,61,79,73); eval("\$"."b"."="."\$"."k"."ey"); push(@import,20,77,69,74,68,'6F',75,74,20,61,20,72,65,67,69,73,74,72,61,74,69,'6F','6E',20,63,'6F',64,65); }; sub checkpass { if (!(($ENV{HTTP_COOKIE}=~/$password/)||($user_data{password} eq $password))) { print "incorrect password. Be sure cookies are enabled on your browser."; print "<A HREF=\"javascript:history.go(-1)\"><h2>Go Back</h2></A>\n"; exit; } else { $userid="admin"; return; }; }; sub memberpass { if ((exists($user_data{username}))&&(exists($user_data{password}))) { $cpass=crypt($value[1],7); $cookie="admin=$value[0]::$cpass"; $ENV{HTTP_COOKIE}=$cookie; } else { $cookie=$ENV{HTTP_COOKIE}; }; open(FILE,"<$members"); @members=<FILE>; close FILE; $ok="false"; foreach (@members) { chop($_); if (($cookie=~/$_/)||($_=~/$cookie/)) { $ok="true"; ($user,$pass)=split(/::/); $userid=$user; }; }; if ($ok eq "false") { &checkpass; }; }; sub datetonum { @parts=split(/\//,$_[0]); if ($parts[2]<100) { if ($parts[2]<20) { $parts[2]+=2000; } else { $parts[2]+=1900; }; }; $result=($parts[2]*1000000)+($parts[0]*1000)+$parts[1]; #FOR EUROPEAN DATES COMMENT OUT THE LINE ABOVE AND UNCOMMENT THE LINE BELOW #result=($parts[2]*10000000)+($parts[1]*10000)+$parts[0]; return($result); }; sub gettype { @typedata=split(/:/,$_[0]); $type=$typedata[0]; if ($type eq "text") {$typesize=$typedata[1];chop($typesize)}; if ($type eq "checkbox\n") {chop($type)}; if ($type eq "list") { chop($typedata[1]); @typelistvals=split(/,/,$typedata[1]); }; if ($type eq "comment") { chop($typedata[1]); $typerows=$typedata[1]; }; };